package edu.gatech.gui;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import edu.gatech.presenters.PatientPresenter;
import edu.gatech.userclasses.Patient;
import javax.swing.JLabel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;

public class PatientPanel {
	private static JButton btnViewAppointments;
	private static JButton btnDisplayInfo;
	private Patient currentPatient;
	private PatientPresenter presenter;
	public PatientPanel(Patient curPatient){
		currentPatient = curPatient;
		JFrame patient = new JFrame("Patient Panel");
		JPanel patientPanel = new JPanel();
		
		patient.getContentPane().add(patientPanel);
		patientPanel.setLayout(null);
		
		btnViewAppointments = new JButton("View Appointments");
		btnViewAppointments.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				presenter = new PatientPresenter(currentPatient);
				presenter.viewAppointment();
			}
		});
		btnViewAppointments.setFont(new Font("Arial", Font.PLAIN, 10));
		btnViewAppointments.setBounds(187, 194, 159, 23);
		patientPanel.add(btnViewAppointments);
		
		btnDisplayInfo = new JButton("Display Info");
		btnDisplayInfo.setFont(new Font("Arial", Font.PLAIN, 10));
		btnDisplayInfo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				presenter = new PatientPresenter(currentPatient);
				presenter.displayInfo();
			}
		});
		btnDisplayInfo.setBounds(187, 228, 159, 23);
		patientPanel.add(btnDisplayInfo);
		
		JPanel panel = new JPanel();
		panel.setBounds(408, 56, 0, 0);
		patientPanel.add(panel);
		panel.setLayout(new BorderLayout(0, 0));
		
		JButton btnSetAppointment = new JButton("Create Appointment\r\n");
		btnSetAppointment.setBounds(187, 262, 159, 21);
		patientPanel.add(btnSetAppointment);
		btnSetAppointment.setFont(new Font("Arial", Font.PLAIN, 10));
		
		JLabel lblHello = new JLabel("Hello,");
		lblHello.setFont(new Font("Arial", Font.PLAIN, 10));
		lblHello.setBounds(60, 36, 46, 14);
		patientPanel.add(lblHello);
		
		JLabel lblNewLabel = new JLabel(currentPatient.getName());
		lblNewLabel.setFont(new Font("Arial", Font.BOLD, 14));
		lblNewLabel.setBounds(60, 54, 246, 23);
		patientPanel.add(lblNewLabel);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_1.setBounds(35, 26, 512, 66);
		patientPanel.add(panel_1);
		
		JButton btnBill = new JButton("Recent Bill");
		btnBill.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				presenter = new PatientPresenter(currentPatient);
				presenter.viewBill();
			}
		});
		btnBill.setFont(new Font("Arial", Font.PLAIN, 10));
		btnBill.setBounds(187, 294, 159, 21);
		patientPanel.add(btnBill);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Actions", TitledBorder.LEADING, TitledBorder.TOP, null, UIManager.getColor("Button.darkShadow")));
		panel_2.setBounds(172, 165, 195, 167);
		patientPanel.add(panel_2);
		btnSetAppointment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				presenter = new PatientPresenter(currentPatient);
				presenter.setAppointment();
			}
		});
		
		MenuBar menuBar = new MenuBar(patient);
		
		patient.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		patient.setSize(600,480);
	    patient.setTitle("Patient Panel");
		patient.setLocationRelativeTo(null);  
		patient.setVisible(true);
	}
}
